from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import UserProfile, Unit



@admin.register(UserProfile)
class UserProfileAdmin(UserAdmin):
    list_display = ('username','name', 'email', 'phone', 'unit', 'created_at', 'updated_at')
    list_display_links = ('username','name',)
    list_filter = ('name', 'email', 'phone', 'unit', 'created_at', 'updated_at')
    search_fields = ()
    fieldsets = (
        ('基本信息', {'fields': ('name', 'email', 'phone', 'unit','is_active','is_staff','is_superuser')}),
        ('密码', {'fields': ('username', 'password')}),
    )


@admin.register(Unit)
class UnitAdmin(admin.ModelAdmin):
    list_display = ('name', 'description', 'created_at', 'updated_at')
    list_display_links = ('name',)
    list_filter = ('name', 'description', 'created_at', 'updated_at')
    search_fields = ('name', 'description', 'created_at', 'updated_at')

admin.site.site_header = '投诉信箱管理员后台'
admin.site.site_title = '投诉信箱'
admin.site.index_title = '投诉信箱'